function formateDate(date) {
    var d = new Date(date)
    var year = d.getFullYear()
    var month = d.getMonth()+1
    var day = d.getDate()
    var hour = d.getHours()
    var min = d.getMinutes()
    var sec = d.getSeconds()
    if (month.length < 2) month = '0' + month;
    if (day.length < 2) day = '0' + day;
    if (hour.length < 2) hour = '0' + hour;
    if (min.length < 2) min = '0' + min;
    if (sec.length < 2) sec = '0' + sec;
    return [year, month, day].join('-')+' '+[hour,min,sec].join(':');
}

function forMateTime(time){//带T类型日期转换
    if(time== null||time == undefined)return
    let arr = time.split("T");
    let d1 = arr[0];
    let darr = d1.split("-");
    let t = arr[1];
    let tarr = t.split(".000");
    let marr = tarr[0].split(":");
    let dd = parseInt(darr[0]) + "/" + parseInt(darr[1]) + "/" + parseInt(darr[2]) + " " + parseInt(marr[0]) + ":" + parseInt(marr[1]) + ":" + parseInt(marr[2]);
    return formatDateTime(dd);
}
function formatDateTime(date) {
    let time = new Date(Date.parse(date));
    time.setTime(time.setHours(time.getHours() + 8));
    let Y = time.getFullYear() + '-';
    let M = addZero(time.getMonth() + 1) + '-';
    let D = addZero(time.getDate()) + ' ';
    let h = addZero(time.getHours()) + ':';
    let m = addZero(time.getMinutes()) + ':';
    let s = addZero(time.getSeconds());
    return Y + M + D + h + m + s;
    // }
}
// 数字补0操作
function addZero(num) {
    return num < 10 ? '0' + num : num;
}
export {formateDate,forMateTime}